<?php 
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '软件下载列表';
?>
<div class="zy_main">
	<div class="container">

        <div class="zy_top_nav font14"><a href="http://www.bwphp.com/">首页</a>  &gt;  软件下载</div>
        <div class="zy_course">
        	<ul>
            	<li class="zmm1">
                	<div class="d1 color99">课程:</div>
                    <div class="d2">
                        <div>
                         <?php if($lists['course']==false){?>
                                <a class="aH" href="<?=Url::toRoute(['download/index', 'removecourse' =>1]);?>">全部</a>
                            <?php }else{?>
                                <a href="<?=Url::toRoute(['download/index', 'removecourse' =>1]);?>">全部</a>
                            <?php }?>   
                        
                        <?php foreach ($course as $key=>$val): ?>
                            <?php if($val['course_id']==$lists['course']){?>
                                <a class="aH" href="<?=Url::toRoute(['download/index', 'course_id' =>$val['course_id']]);?>"><?=Html::encode($val['course_name'])?></a>
                            <?php }else{?>
                                <a href="<?=Url::toRoute(['download/index', 'course_id' =>$val['course_id']]);?>"><?=Html::encode($val['course_name'])?></a>
                            <?php }?>                        
                        <?php endforeach;?>                    
                        </div>
                    </div>
                </li>
                <li class="zmm2">
                	<div class="d1 color99">分类:</div>
                    <div class="d2"><div>
                        <?php if($lists['cate']==false){?>
                                <a class="aH" href="<?=Url::toRoute(['download/index', 'removecate' =>1]);?>">全部</a>
                            <?php }else{?>
                                <a href="<?=Url::toRoute(['download/index', 'removecate' =>1]);?>">全部</a>
                            <?php }?>
                        
                        <?php foreach ($cate as $key=>$val): ?>
                            <?php if($val['softcate_id']==$lists['cate']){?>
                                <a class="aH" href="<?=Url::toRoute(['download/index', 'cate_id' =>$val['softcate_id']]);?>"><?=Html::encode($val['softcate_name'])?></a>
                            <?php }else{?>
                                <a href="<?=Url::toRoute(['download/index', 'cate_id' =>$val['softcate_id']]);?>"><?=Html::encode($val['softcate_name'])?></a>
                            <?php }?>  
                                                
                        <?php endforeach;?>                           
                    </div></div>
                </li>
            </ul>
        </div>

      	<ul class="zy_course_list">
             <?php foreach ($lists['lists'] as $key=>$val): ?>                       
                <li class='tuwen'   style="position:relative; border-radius:15px;" data-id='<?=$val['soft_id']?>'>

                        <p><img alt="<?=$val['soft_name']?>" style='padding:5px; text-align:center; border-radius:15px; border:1px #dcdbd1 solid' src="<?= 'http://files.bwphp.com/file/image/show/275/175?path='.$val['soft_thumb']?>"></p>

                        <div style='margin-left:10px;'>
                            <p>软件名称：<span class="font14"><?=Html::encode($val['soft_name'])?></span></p>
                            <p>类别：<span class="color99"><?=Html::encode($val['softcate_name'])?></span></p>
                            <p>软件大小：<span class="color99"><?=Html::encode($val['soft_size'])?>/M</span></p>
                            <p>所需积分：<span class="color99"><?=Html::encode($val['soft_points'])?></span></p>
                            <p>下载次数：<span class="color99"><?=Html::encode($val['soft_down_count'])?></span></p>
                        </div>
                     <div id='down<?=$val['soft_id']?>' style='border-radius:15px; position: absolute;  width:100%; height:100%;top:0px;display: none;z-index:49; padding:0;'>   
                    <div  style="background:black; z-index:50; border-radius:15px; position: absolute;  width:100%; height:100%;  opacity:0.6;  ">
                        <div style='height:200px;'>
                             <h4>相关课程：</h4> <br/>
                             <ul id='now<?=$val['soft_id']?>' ></ul>
                        </div>                        
                    </div>
                    <div style="height:90px; position: absolute; top:220; left:10px; z-index:51">
                             <a class='downloadclass' style='background:#0997F7;border-radius:20px; color:white; width:160px; text-align:center; margin-left:29px; font-size:20;' href='javascript:void(0)' data-id='<?=$val['soft_id']?>' >点击下载</a>   
                    </div>
                    </div>
                </li>
             <?php endforeach;?> 
        
        </ul>
        <script type="text/javascript">
			$(function(){
				var noid = 0;				
				$('.tuwen').hover(function(){					
					var id = $(this).attr('data-id');	
					timer = setTimeout(function(){					
						$('#down'+id).slideDown(100);
						if($('#now'+id).html()==''){
							if(noid==0){
    							noid = noid+1;    							
        						$.ajax({
        							url:'http://www.bwphp.com/index.php/download/course',
        							type: 'post',
        							data:'soft_id='+id,
        							dataType:'json',
        							success:function(msg){
        								str = '';
        								for(var i=0;i<msg.length;i++){
        									str+='<li style="background:black; text-align:center; color:white; overflow: hidden; height: 25px; " title='+msg[i]['course_name']+'>'+msg[i]['course_name']+'</li>';
        								}    																
        									$('#now'+id).append(str);
        									
        							},
        							complete:function(){
        								noid = 0;
            						}
        						});
						     }
						 }
					  },500);	 
					},function(){
						var id = $(this).attr('data-id');
						//$('#now'+id).empty();
						clearTimeout(timer);
						$('#down'+id).slideUp(200);
				});

				var id = 0 ;
				$('.downloadclass').on('click',function(){
					id = $(this).attr('data-id');					
					$.ajax({
						url:'<?php echo Url::to(['download/downloadsoft']);?>',
						type: 'post',
						data:'soft_id='+id,
						dataType:'json',
						success:function(msg) {
							if(msg.data==0) {
								jq('#loginModal').modal('show');
							}else if(msg.data==1) {
								jq('#downloaderror').modal('show');
							}else if(msg.data==2) {
								jq('#downtishi').html(msg.info);
								jq('#downloaddel').modal('show');
							}else if(msg.data==3){
								jq('#downtishi').html(msg.info);
								jq('#downloaddel').modal('show');
							}
						}
					});
				});

				$('#downsofturl').bind('click',function(){
					$.ajax({
						url:'<?php echo Url::to(['download/downloadsoft']);?>',
						type: 'post',
						data:'soft_id='+id+'&bloor=1&is_alow=1',
						dataType:'json',
						success:function(msg) {
							if(msg.data==0) {
								jq('#loginModal').modal('show');
							}else if(msg.data==1) {
								jq('#downloaderror').modal('show');
							}else if(msg.data==2) {
								jq('#downtishi').html(msg.info);
								jq('#downloaddel').modal('show');
							}else if(msg.data==3){
								jq('#downtishi').html(msg.info);
								jq('#downloaddel').modal('show');
							}
						}
					});
				});
			});
        </script>
        
        <div style="" class="zypage yahei marginB38">
          <div class="zypage_div" style="-moz-user-select: none;">
               <?php echo LinkPager::widget([
				'pagination' => $lists['paging'],
				//'firstPageLabel'=>"首页",
				'prevPageLabel'=>'上一页',
				'nextPageLabel'=>'下一页',
				//'lastPageLabel'=>'尾页',
			]);?>
        </div>        
    </div>
</div>
<!--不能重复积分弹框-->
<div class="modal fade" id="downloaderror" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-sm" style="top:150px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span><button>
                <h4 class="modal-title" style="font-size: 18px;">消息提示</h4>
            </div>
            <div class="modal-body">
                <section class="box-login v5-input-txt" id="box-login">
                        <center><h4 style="font-size: 18px;margin-bottom: 20px;">您的积分不足</h4>
                        <button data-dismiss="modal"  style="width: 150px;" type="button" class="btn btn-micv5 btn-block">确定<button></center>
						
                <section>
            </div>
        </div>
    </div>
</div>
<!--不能重复扣除积分弹框-->
<div class="modal fade" id="downloaddel" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-sm" style="top:150px;">
        <div class="modal-content" style="width:500px; left:-40px;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span><button>
                <h4 class="modal-title" style="font-size: 18px;">消息提示</h4>
            </div>
            <div class="modal-body">
                <section class="box-login v5-input-txt" id="box-login">
                        <center><h4 style="font-size: 18px;margin-bottom: 20px;" id='downtishi'></h4>
                        <button id='downsofturl' data-dismiss="modal"  style="width: 150px; float:left; margin-left:30px; margin-right:30px" type="button" class="btn btn-micv5 btn-block">确定<button></center>
                        <button data-dismiss="modal" style="width: 150px; margin-left:30px; margin-top:-7px; background: #e02f1a;" type="button" class="btn btn-micv5 btn-block">取消</button><button></button></center>
                <section>
            </div>
        </div>
    </div>
</div>
